/*
 * Model.h
 *
 *  Created on: 30.10.2012
 *      Author: Martin
 */

#pragma once

#include <GLee.h>

#ifdef _WIN32 
#include <windows.h> 
#include "SDL_thread.h"
#else
#include "SDL/SDL_thread.h"
#endif

#include <string>
#include <cstring>
#include <stdio.h>
#include <vector>
#include "../TexPool.h"
#include <glm/glm.hpp>
#include "../special/VBOIndexer.h"
#include "../dataTypes/Cube.h"

// ex.: building.obj has building_col.obj bounding box
const std::string COL = "_col";

class Model
{
public:
	Model(std::string _filename, std::string _dir);
	virtual ~Model();

	int loadModel(std::string exfile);

	// loading bounding box
	void loadBBox();

	void createBufferObject();

	// draw model
	void draw();

	// draw bounding box
	void drawBoundingBox(glm::vec3 pos, float angle);

	std::string getFName();
	bool isIsThereBBox() const;
	void setIsThereBBox(bool isThereBBox);
	// vector of bounding box
	DataTypes::Cube *boundingBox;
private:
	std::string filename, dir; // filename model, directory

	TexPool textures;

	// all indexed
	std::vector<glm::vec3> indexed_vertices; // vertices
	std::vector<glm::vec2> indexed_uvs; // uvs coord
	std::vector<glm::vec3> indexed_normals; // normals
	std::vector<unsigned short> indices; // indexing

	GLuint tex;

	// handle id of buffers
	GLuint vertexbuffer;
	GLuint uvbuffer;
	GLuint normalbuffer;
	GLuint elementbuffer;

	bool isThereBBox;
};

